<template>
  <div id="app">
    <keep-alive include="EditAddress">
      <router-view/>
    </keep-alive>
  </div>
</template>
<script>
import { mapState } from 'vuex'
export default {
  name: 'App',
  computed: {
    ...mapState('user', ['token', 'location'])
  },
  created () {
    this.initGlobalData()
  },
  methods: {
    initGlobalData () {
      // console.log(this.$route)
      if (!this.location && ['/select/location', '/geolocation'].indexOf(this.$route.path) === -1) {
        this.$router.push({
          path: '/geolocation',
          query: {
            callbackUrl: this.$route.path
          }
        })
      }
      if (this.token) {
        this.$store.dispatch('user/getUserInfo')
      }
    }
  }
}
</script>
<style lang="scss">
#app {
  min-height: 100vh;
  width: 100vw;
  background: #F8F8F8;
}
</style>
